<route lang="json5" type="home">
{
  style: {
    navigationStyle: 'custom',
    navigationBarTitleText: '引导页',
  },
}
</route>

<template>
  <view class="bg-white overflow-hidden" :style="{ height: `${windowHeight}px` }">
    <code-guide v-if="guidePages" />
  </view>
</template>

<script lang="ts" setup>
import codeGuide from '@/components/code-guide.vue'
// 获取屏幕边界到安全区域距离
const { safeAreaInsets, windowHeight } = uni.getSystemInfoSync()

const guidePages = ref(false)

/**
 * 获取本地存储中launchFlag的值
 * 若存在，说明不是首次启动，直接进入首页；
 * 若不存在，说明是首次启动，进入引导页；
 */
function loadExecution() {
  try {
    // 获取本地存储中launchFlag标识
    const value = uni.getStorageSync('launchFlag')
    if (value) {
      uni.reLaunch({
        url: '/pages/index/index',
      })
    } else {
      guidePages.value = true
    }
  } catch (e) {
    guidePages.value = true
    uni.setStorage({
      key: 'launchFlag',
      data: true,
      success: function () {
        console.log('error时存储launchFlag')
      },
    })
  }
}
onLoad(() => {
  loadExecution()
})
</script>

<style lang="scss" scoped></style>
